import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'

/**
 * hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
 *                                if not set alwaysShow, only more than one route under the children
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noredirect           if `redirect:noredirect` will no redirct in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
  }
 **/
export const constantRouterMap = [{
        path: '/login',
        component: () =>
            import ('@/views/login/index'),
        hidden: true
    },
    {
        path: '/404',
        component: () =>
            import ('@/views/404'),
        hidden: true
    },
    {
        path: '',
        component: Layout,
        redirect: '/home',
        children: [{
            path: 'home',
            name: 'home',
            component: () =>
                import ('@/views/home/index'),
            meta: { title: '首页', icon: 'home' }
        }]
    }
]

export const asyncRouterMap = [{
        path: '/log',
        component: Layout,
        redirect: '/log/adminLog',
        name: 'log',
        meta: { title: '日志管理', icon: 'log' },
        children: [{
            path: 'adminLog',
            name: 'adminLog',
            component: () =>
                import ('@/views/log/adminLog/index'),
            meta: { title: '系统日志', icon: 'log-admin' }
        }, {
            path: 'userLog',
            name: 'userLog',
            component: () =>
                import ('@/views/log/userLog/index'),
            meta: { title: "用户日志", icon: 'log-user' }
        }]
    },
    {
        path: '/crm',
        component: Layout,
        redirect: '/crm/user',
        name: 'crm',
        meta: { title: '用户管理', icon: 'crm' },
        children: [{
                path: 'user',
                name: 'userList',
                component: () =>
                    import ('@/views/crm/user/index'),
                meta: { title: '用户列表', icon: 'crm-user-list' }
            },
            {
                path: 'userDetail',
                name: 'userDetail',
                component: () =>
                    import ('@/views/crm/user/userDetail'),
                meta: { title: '用户详情' },
                hidden: true
            },
            {
                path: 'userPortrait',
                name: 'userPortrait',
                component: () =>
                    import ('@/views/crm/userPortrait/index'),
                meta: { title: '兴趣画像', icon: 'crm-user-portrait' }
            }
        ]
    }, {
        path: '/sms',
        component: Layout,
        redirect: '/sms/banner',
        name: 'sms',
        meta: { title: '系统管理', icon: 'sms' },
        children: [{
                path: 'partition',
                name: 'partition',
                component: () =>
                    import ('@/views/cms/partition/index'),
                meta: { title: '分区列表', icon: 'cms-partition' }
            },
            {
                path: 'tag',
                name: 'tag',
                component: () =>
                    import ('@/views/cms/tag/index'),
                meta: { title: '标签管理', icon: 'cms-tag' }
            },
            {
                path: 'policy',
                name: 'policy',
                component: () =>
                    import ('@/views/cms/policy/index'),
                meta: { title: '政务要闻', icon: 'cms-policy' }
            }, {
                path: 'addPolicy',
                name: 'addPolicy',
                component: () =>
                    import ('@/views/cms/policy/add'),
                meta: { title: '添加政务要闻' },
                hidden: true
            },
            {
                path: 'updatePolicy',
                name: 'updatePolicy',
                component: () =>
                    import ('@/views/cms/policy/update'),
                meta: { title: '编辑政务要闻' },
                hidden: true
            },
            {
                path: 'banner',
                name: 'homeBanner',
                component: () =>
                    import ('@/views/sms/banner/index'),
                meta: { title: '轮播图管理', icon: 'sms-banner' }
            },
            {
                path: 'addBanner',
                name: 'addHomeBanner',
                component: () =>
                    import ('@/views/sms/banner/add'),
                meta: { title: '添加轮播图' },
                hidden: true
            },
            {
                path: 'updateBanner',
                name: 'updateHomeBanner',
                component: () =>
                    import ('@/views/sms/banner/update'),
                meta: { title: '编辑轮播图' },
                hidden: true
            },
            {
                path: 'sensitive',
                name: 'sensitive',
                component: () =>
                    import ("@/views/sms/sensitive/index"),
                meta: { title: '敏感词管理', icon: 'sms-sensitive' }
            }, {
                path: 'dataset',
                name: 'dataset',
                component: () =>
                    import ('@/views/sms/dataset/index'),
                meta: { title: '数据集管理', icon: 'sms-dataset' }
            },
            {
                path: 'addDataset',
                name: 'addDataset',
                component: () =>
                    import ('@/views/sms/dataset/add'),
                meta: { title: '添加数据集' },
                hidden: true
            },
            {
                path: 'updateDataset',
                name: 'updateDataset',
                component: () =>
                    import ('@/views/sms/dataset/update'),
                meta: { title: '修改数据集' },
                hidden: true
            }, {
                path: 'knowledge',
                name: 'knowledge',
                component: () =>
                    import ('@/views/sms/knowledge/index'),
                meta: { title: '知识库管理', icon: 'sms-knowledge' }
            },
            {
                path: 'addKnowledge',
                name: 'addKnowledge',
                component: () =>
                    import ('@/views/sms/knowledge/add'),
                meta: { title: '添加知识库' },
                hidden: true
            },
            {
                path: 'updateKnowledge',
                name: 'updateKnowledge',
                component: () =>
                    import ('@/views/sms/knowledge/update'),
                meta: { title: '编辑知识库' },
                hidden: true
            },
        ]
    },
    {
        path: '/ums',
        component: Layout,
        redirect: '/ums/admin',
        name: 'ums',
        meta: { title: '权限', icon: 'ums' },
        children: [{
                path: 'admin',
                name: 'admin',
                component: () =>
                    import ('@/views/ums/admin/index'),
                meta: { title: '管理员列表', icon: 'ums-admin' }
            },
            {
                path: 'role',
                name: 'role',
                component: () =>
                    import ('@/views/ums/role/index'),
                meta: { title: '角色列表', icon: 'ums-role' }
            },
            {
                path: 'allocMenu',
                name: 'allocMenu',
                component: () =>
                    import ('@/views/ums/role/allocMenu'),
                meta: { title: '分配菜单' },
                hidden: true
            },
            {
                path: 'allocResource',
                name: 'allocResource',
                component: () =>
                    import ('@/views/ums/role/allocResource'),
                meta: { title: '分配资源' },
                hidden: true
            },
            {
                path: 'menu',
                name: 'menu',
                component: () =>
                    import ('@/views/ums/menu/index'),
                meta: { title: '菜单列表', icon: 'ums-menu' }
            },
            {
                path: 'addMenu',
                name: 'addMenu',
                component: () =>
                    import ('@/views/ums/menu/add'),
                meta: { title: '添加菜单' },
                hidden: true
            },
            {
                path: 'updateMenu',
                name: 'updateMenu',
                component: () =>
                    import ('@/views/ums/menu/update'),
                meta: { title: '修改菜单' },
                hidden: true
            },
            {
                path: 'resource',
                name: 'resource',
                component: () =>
                    import ('@/views/ums/resource/index'),
                meta: { title: '资源列表', icon: 'ums-resource' }
            },
            {
                path: 'resourceCategory',
                name: 'resourceCategory',
                component: () =>
                    import ('@/views/ums/resource/categoryList'),
                meta: { title: '资源分类' },
                hidden: true
            }
        ]
    },
    {
        path: '/cms',
        component: Layout,
        redirect: '/cms/partition',
        name: 'cms',
        meta: { title: '内容管理', icon: 'cms' },
        children: [{
                path: 'video',
                name: 'video',
                component: () =>
                    import ('@/views/cms/video/index'),
                meta: { title: '视频管理', icon: 'cms-video' }
            },
            {
                path: 'updateVideo',
                name: 'updateVideo',
                component: () =>
                    import ('@/views/cms/video/update'),
                meta: { title: '修改视频信息' },
                hidden: true
            },
            {
                path: 'comment',
                name: 'comment',
                component: () =>
                    import ('@/views/cms/comment/index'),
                meta: { title: '评论管理', icon: 'cms-comment' }
            }, {
                path: 'commentDetail',
                name: 'commentDetail',
                component: () =>
                    import ("@/views/cms/comment/detail"),
                meta: { title: "查看评论详情" },
                hidden: true
            },
            {
                path: 'news',
                name: 'news',
                component: () =>
                    import ('@/views/cms/news/index'),
                meta: { title: '动态管理', icon: 'cms-news' }
            },
            {
                path: 'expShare',
                name: 'expShare',
                component: () =>
                    import ('@/views/cms/expShare/index'),
                meta: { title: '经验分享', icon: 'cms-exp-share' }
            }, {
                path: 'expShareDetail',
                name: 'expShareDetail',
                component: () =>
                    import ("@/views/cms/expShare/detail"),
                meta: { title: "查看文章详情" },
                hidden: true
            },
            {
                path: 'agriResource',
                name: 'agriResource',
                component: () =>
                    import ('@/views/cms/agriResource/index'),
                meta: { title: '农业资源', icon: 'cms-agri-resource' }
            },
            {
                path: 'agriResourceDetail',
                name: 'agriResourceDetail',
                component: () =>
                    import ('@/views/cms/agriResource/detail'),
                meta: { title: '查看资源详情' },
                hidden: true
            },
            {
                path: 'question',
                name: 'question',
                component: () =>
                    import ('@/views/cms/question/index'),
                meta: { title: '农技问答', icon: 'cms-question' }
            },
            {
                path: 'questionDetail',
                name: 'questionDetail',
                component: () =>
                    import ('@/views/cms/question/detail'),
                meta: { title: '查看问答详情' },
                hidden: true
            },
        ]
    },
    { path: '*', redirect: '/404', hidden: true }
]

export default new Router({
    mode: 'history', //后端支持可开
    scrollBehavior: () => ({ y: 0 }),
    routes: constantRouterMap
})